package com.yuanduan.mplus.view;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.cj.framework.app.BaseActivity;
import com.yuanduan.mplus.R;
import com.yuanduan.mplus.config.Config;

public class NotifyActivity extends BaseActivity {
    private Toolbar toolbar;
    private WebView webView;

    @Override
    protected void findId() {
        toolbar= (Toolbar) findViewById(R.id.toolbar);
        webView= (WebView) findViewById(R.id.notify_webview);
    }

    @Override
    protected void logic() {
        toolbar.setTitle("通知");
        toolbar.setTitleTextColor(android.R.color.black);
        toolbar.setNavigationIcon(R.mipmap.back_arrow_black);
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NotifyActivity.this.finish();
            }
        });
        WebSettings webSettings=webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webView.loadUrl(Config.URL+Config.TONGZHI);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });
    }

    @Override
    protected int setLayout() {
        return R.layout.activity_notify;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode==KeyEvent.KEYCODE_BACK&&webView.canGoBack()){
            webView.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
